Unified Report Specifications

This pack provides:
* interchanges - The CDS interchanges used to generate the example reports
* reports - Example reports generated from the same data for SEM, PbR, and Unified
* schema - Documentation of the unified structure as a 'properties' CSV view and a JSON-Schema

The reports are encoded as JSON Lines (http://jsonlines.org/). Each line is terminated by '\n' and contains a JSON object. An JSON viewer can be used to examine the content of each line (e.g. http://jsonviewer.stack.hu/).

The reports are generated from the following CDS dataset types:
* admitted_patient_care: 120, 130, 140

While the domain-level detail of each report varies, a common structure is used for system / interchange / protocol related properties. For example:

{
  "type": "<report_type>",
  "action": "insert|delete|patch",
  "schema_version": 1,
  "system": {
    "interchange": {
      // SUS+ interchange details
    },
    "transaction": {
      // Specified CDS transaction / protocol details
    },
    "record": {
      // CDS record level details, both specified on the record and SUS+ / system generated identifiers, reasons for access, etc
    },
    "report": {
      // Metadata about the generated report
    }
  },

  // Continues with dataset / domain-specific details
}


Typically the 'grain' of the report is at the CDS record level. The exception being admitted_patient_care where each line in the report represents a complete APC spell. In turn the APC spell contains all episode records and critical care records associated with the spell. For example a basic outline of an APC record:

{
    "type": "admitted_patient_care",    
    "system": {
        // Metadata / system-generated details about the APC Spell
    },

    "spell": {
        // 'Canonical' / SUS+ determined values applicable for the spell such as admission / discharge
        // These values are provided on each individual CDS record, but may vary across the episodes in the spell
        // The values here are equivalent to the PbR Spell report
        
        "episodes": [
            {
               // Values associated with the spell as a whole (such as admission/discharge details)
               // are provided per episode as well as the 'canonical' value provided at the spell-level.
               // The spell-values provided per episode are the original values carried on that episode's XML record.
            
                "system": {
                    // Metadata / system-generated details about the episode CDS record
                },
                
                "critical_care_specified": [
                {
                    // A view of all critical care periods that were specified on this episode's XML record
                    // This view is closest to the original SEM reports, it contains all critical care periods including duplicates
                    // For a canonical view of the spell's critical care periods, see critical_care_consolidated
                },

                // Further critical care periods specified on the episode record appear here
            ]

                // Continues with further details about the record...
            },

            // Further episodes in the spell appear here
        ],
        
        "critical_care_consolidated": [
            {
                // A consolidated / SUS+ 'canonocal' view of critical care for the APC Spell
                // For SEM-like purposes a link is provided to the CDS record that 'carried' the critical care period (see critical_care_submitted)
                // For PbR-like purposes this view only contains critical care periods which have been associated/allocation to an episode and duplicates are removed

                // Details about the critical care period (e.g. admission, unit, discharge, organ_support_days, LOS days, etc)
            },

            // Further critical care periods in the spell appear here
        ]
    }    
}

When producing deltas, a second file containing the records to delete is also produced. This must be applied before the inserts.
Please note that as APC reports are at the granularity of spell rather than episode, the id to delete corresponds to the spell to be deleted (i.e. all episodes in the spell of this ID must be removed).
